
/*
 * @Desc:
 * @Author: LIUBIN
 * @version: 0.1
 * @Date: 2025-09-01 00:10:34
 */
#ifndef BSP_KEY_H
#define BSP_KEY_H

#include "main.h"

#define KEY_PRESS_TIME_MS 500
#define KEY_LONG_PRESS_TIME_MS 1000
#define KEY_DOUBLE_CLICK_TIME_MS 200 // ˫��ʱ����

#define KEY_SCAN_TIC 10 // 10MS ����ɨ��

enum KEY_EVENT
{
  KEY_EVENT_NONE = 0,
  KEY_EVENT_PRESS,
  KEY_EVENT_RELEASE,
  KEY_EVENT_LONG_PRESS,
  KEY_EVENT_DOUBLE_CLICK,
};

typedef struct
{
  uint8_t key_val;
  uint8_t key_val_old;
  uint8_t key_status;

  uint8_t key_cnt;       // ��������
  uint16_t key_tic_cnt1; // �Ӱ��µ����ֵ�ʱ��
  uint16_t key_tic_cnt2; // ��һ�ΰ��µ��ڶ��ΰ��µ�ʱ��

  uint8_t event;
  uint8_t (*read)(void);

} bsp_key_t;

void bsp_key_init(bsp_key_t* key);
void bsp_key_proc(bsp_key_t* key);

extern bsp_key_t key;
#endif
